VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "DAOPerfil"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes"
Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
Option Explicit
Private mvarConnection As utilConexion
Public Sub setConnection(ByVal vData As utilConexion)
    Set mvarConnection = vData
End Sub
Public Function guardarNuevo(bean As bperfil) As Boolean
Dim sql As String
sql = "INSERT INTO perfil(sDescripcion,nBloqueado) VALUES ('" + bean.sdescripcion + "',0)"
mvarConnection.Connection.Execute sql
End Function
Public Function eliminar(bean As bperfil) As Integer
On Error GoTo hnderr
Dim sql As String
sql = "DELETE FROM perfil WHERE nCodigo= " + CStr(bean.nCodigo)
mvarConnection.Connection.Execute sql
eliminar = UtilConstantes.OPT_DATOS_ELIMINADOS
hnderr:
If Err.Number = 0 Then Exit Function
eliminar = UtilConstantes.OPT_ERROR_ENCONTRADO
Err.Clear
End Function
Public Function actualizar(bean As bperfil) As Integer
Dim sql As String
sql = "UPDATE perfil SET sDescripcion='" + bean.sdescripcion + "' WHERE nCodigo= " + CStr(bean.nCodigo)
mvarConnection.Connection.Execute sql
actualizar = UtilConstantes.OPT_DATOS_GUARDADOS
End Function
Public Function getLista() As Collection
Dim sql As String
Dim rst As New Recordset
Dim list As New Collection
Dim record As New bperfil
sql = "SELECT nCodigo, sDescripcion FROM perfil"
rst.Open sql, mvarConnection.Connection, adOpenForwardOnly
While Not rst.EOF
    Set record = New bperfil
    If Not IsNull(rst.Fields("nCodigo")) Then record.nCodigo = rst.Fields("nCodigo").value
    If Not IsNull(rst.Fields("sDescripcion")) Then record.sdescripcion = rst.Fields("sDescripcion").value
    rst.MoveNext
    list.Add record
Wend
Set getLista = list
End Function
